public class Demo {
    public static int[] shortestDistanceAfterQueries(int n, int[][] queries) {
        int x=queries.length; //小于n-1
        int y=queries[0].length;//就是2
        //接下来考虑如何计算最短路径长度，先计算一个
        int []arr=new int[x*y];
        for(int i=0;i<y;i++){
            for(int j=0;j<y;j++){
                int a=0;
                arr[a]=queries[i][j];
            }
        }
        int temp=0;//当成目标点;
        int sum=0;//路径长度
        int []answer=new int[x-1];
        while(temp<n-1){  //x等于1的解法
            int b=0;
            int cha=queries[b][1]-queries[b][0];//差值
            for(int i=0;i<cha;i++) {
                temp++;
            }
            b=1;
            if(b==x){
                sum=n-1-temp;
                temp=n-1;
                answer[b-1]=sum;
            }
        }
        return answer;
    }

    public static void main(String[] args) {
        int [][]arr=new int[1][2];
        arr[0][0]=2;
        arr[0][1]=4;
        int n=5;
        int []arr1=new int[1];
        arr1=shortestDistanceAfterQueries(n,arr);
        System.out.println(arr1);
    }
}
